<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-download" size="mini" :disabled="excel_disable" @click="excel_out">转档</el-button>
      </el-col>
    </el-row>
    <hd-table
      id="tabMoudleWork"
      highlight-current-row
      @scrollBottom="get_info"
      border
      height="100%"
      :readOnly="true"
      :columns="sys_m"
      v-model="sys_m_data_show"
      :loading="loading"></hd-table>
  </div>
</template>

<script>
import BoardService from '@/api/board/board'
import { exportTable } from '@/utils/ruoyi'
// import moment from "moment";
export default {
  data() {
    return {
      date: new Date(),
      now_data: {},
      excel_disable: true,
      loading: false,
      total: 21,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
      },
      sys_m: [
        {
          type: 'index',
          width: 50,
          align: 'center',
          fixed: 'left',
        },
        {
          title: '机台',
          key: 'hmmJtbh',
          width: 80,
          sortable: true,
        },
        {
          title: '组别',
          key: 'hmmBbdm',
          width: 80,
          sortable: true,
        },

        {
          title: '物料代码',
          key: 'hmmWldm',
          width: 150,
          sortable: true,
        },
        {
          title: '当前模具',
          key: 'hmmMjbh',
          sortable: true,
        },
        {
          title: '当前模具名称',
          key: 'hmmMjmc',
          sortable: true,
        },
        {
          title: '预计下模时间',
          key: 'hmmYjxxsj',
          width: 150,
          sortable: true,
        },
        {
          title: '下一模具',
          key: 'hmmNextmjbh',
          sortable: true,
        },
        {
          title: '下一模具名称',
          key: 'hmmNextmjmc',
          sortable: true,
        },
        {
          title: '材质',
          key: 'hmmNextczdm',
          sortable: true,
        },
        {
          title: '颜色',
          key: 'hmmNextysdm',
          width: 80,
          sortable: true,
        },
        {
          title: '计划数量',
          key: 'hmmNextscsl',
          width: 90,
          sortable: true,
        },
        {
          title: '净重(KG)',
          key: 'hmmNextjz',
          width: 100,
          sortable: true,
        },
        {
          title: '原料重量(KG)',
          key: 'hmmNextylzl',
          width: 110,
          sortable: true,
        },
      ],
      sys_m_data_show: [],
      sys_m_data: [],
    }
  },
  mounted() {
    this.get_info()
  },
  methods: {
    excel_out() {
      exportTable('#tabMoudleWork div', '机台')
    },
    get_info() {
      this.loading = true
      this.excel_disable = false
      if (this.queryParams.pageNum < Math.ceil(this.total / this.queryParams.pageSize)) {
        BoardService.getModelStateBoard(this.queryParams).then((response) => {
          this.sys_m_data_show = this.sys_m_data_show.concat(response.rows)
          this.queryParams.pageNum++
          this.total = response.total
          this.loading = false
        })
      }
    },
    backStorage() {
      // 返回上级路由并关闭当前路由
      this.$store.state.tagsView.visitedViews.splice(
        this.$store.state.tagsView.visitedViews.findIndex((item) => item.path === this.$route.path),
        1
      )
      this.$router.push({ path: '/index' })
    },
  },
}
</script>
